<template>
  <div>
    <div class="container radiusBottom">
      <div class="images">
        <div class="img">
          <img :src="styleUrls[dataJson.type][dataJson.stylesType]" />
        </div>
        <div class="buttonSetStyle" @click="alertTag">修改样式</div>
      </div>
    </div>
    <div class="container">
      <div v-if="dataJson.stylesType == 0" class="line">
        <div class="left ">选择图片</div>
        <div class="imgContent ">
          <img :src="dataJson.imgUrl" />
          <p class="describe">建议尺寸：750px*288px</p>
        </div>
        <div>
          <el-button class="btn" @click="showTag">上传图片</el-button>
        </div>
      </div>
      <div class="line">
        <div class="left ">背景颜色</div>
        <div class="colorOption">
          <div class="divs">
            {{ dataJson.backgroundColor }}
          </div>

          <el-color-picker
            v-model="dataJson.backgroundColor"
            show-alpha
            size="medium"
            class="colorPicker"
          ></el-color-picker>
        </div>
      </div>
      <div class="line">
        <div class="left ">名称颜色</div>
        <div class="colorOption">
          <div class="divs">
            {{ dataJson.color }}
          </div>

          <el-color-picker
            v-model="dataJson.color"
            show-alpha
            size="medium"
            class="colorPicker"
          ></el-color-picker>
        </div>
      </div>
    </div>
    <images-material
      :dialog-images="dialogImages"
      :use-btn="true"
      :use-type="'all'"
      @close="close"
    />
  </div>
</template>

<script>
import { styleUrls } from "../../data";
export default {
  components: {
    ImagesMaterial: r =>
      require.ensure([], () => r(require("publicCom/imgupdate")), "imgupdate")
  },
  props: {
    dataJson: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      styleUrls,
      dialogImages: false
    };
  },
  methods: {
    alertTag() {
      this.$emit("alertTag", true, this.dataJson.stylesType, 17);
    },
    showTag() {
      this.dialogImages = true;
    },
    close(file) {
      this.dialogImages = false;
      if (!file) return;
      const imgSrc =
        this.$store.state.qiniu + file.file_path + this.$store.state.imgRotate;
      this.dataJson.imgUrl = imgSrc;
    }
  }
};
</script>

<style lang="scss" scoped>
@import "~@/assets/scss/decorate.scss";
</style>
